// rem適配 上线用这里
// (function (doc, win) {
//     var docEl = doc.documentElement,
//         resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
//         recalc = function () {
//             var clientWidth = docEl.clientWidth;
//             if (!clientWidth) return;
//             docEl.style.fontSize = 20 * (clientWidth / 375) + 'px';
//         };
//     recalc();
//     if (!doc.addEventListener) return;
//     win.addEventListener(resizeEvt, recalc, false);
// })(document, window);
// 检测是否到底部
// const scrollObj = {
//     getScrollTop () {
//         let [ scrollTop, bodyScrollTop, documentScrollTop ] = [0, 0, 0];
//         if (document.body) {
//             bodyScrollTop = document.body.scrollTop;
//         }
//         if (document.documentElement) {
//             documentScrollTop = document.documentElement.scrollTop;
//         }
//         scrollTop = (bodyScrollTop - documentScrollTop > 0) ? bodyScrollTop : documentScrollTop;
//         return scrollTop;
//     },
//     getScrollHeight () {
//         let [scrollHeight, bodyScrollHeight, documentScrollHeight] = [0, 0, 0];
//         if (document.body) {
//             bodyScrollHeight = document.body.scrollHeight;
//         }
//         if (document.documentElement) {
//             documentScrollHeight = document.documentElement.scrollHeight;
//         }
//         scrollHeight = (bodyScrollHeight - documentScrollHeight > 0) ? bodyScrollHeight : documentScrollHeight;
//         return scrollHeight;
//     },
//     getWindowHeight () {
//         return document.body.clientHeight;
//     },
//     isBottom () {
//         // 如果到底部了返回true
//         if (this.getScrollTop() + this.getWindowHeight() === this.getScrollHeight()) {
//             return true;
//         }
//     }
// };
document.addEventListener('DOMContentLoaded', function () {
    // rem適配 本地用这里
    (function (doc, win) {
        let docEl = doc.documentElement;
        let resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize';
        let recalc = function () {
            let clientWidth = docEl.clientWidth;
            if (!clientWidth) return;
            docEl.style.fontSize = 20 * (clientWidth / 375) + 'px';
        };
        recalc();
        if (!doc.addEventListener) return;
        win.addEventListener(resizeEvt, recalc, false);
    })(document, window);
    // 阻止双击放大
    let lastTouchEnd = 0;
    document.addEventListener('touchstart', function (event) {
        if (event.touches.length > 1) {
            event.preventDefault();
        }
    });
    document.addEventListener('touchend', function (event) {
        let now = (new Date()).getTime();
        if (now - lastTouchEnd <= 300) {
            event.preventDefault();
        }
        lastTouchEnd = now;
    }, false);
    // 阻止双指放大
    document.addEventListener('gesturestart', function (event) {
        event.preventDefault();
    });
    // 阻止滑动
    // document.addEventListener('touchmove', function (e) {
    //     // if (scrollObj.isBottom()) {
    //     //     e.preventDefault();
    //     // }
    //     e.preventDefault();
    // });
    document.body.addEventListener('scroll', function (e) {
        e.preventDefault();
    }, { passive: false });
});
